<?php

class CounterController extends Controller {

    public $layout='backend.views.layouts.column1';

    /**
     * @var CActiveRecord the currently loaded data model instance.
     */
    private $_model;

    public function actionIndex() {
        $criteria=new CDbCriteria(array('order'=>'id_view DESC',));

        $pag  = 50;
        if(isset($_POST['search'])){
            $criteria->compare('ip',$_POST['ip'],true);
            $criteria->compare('c_date',$_POST['date'],true);
            $criteria->compare('page',$_POST['page'],true);

            $info['date'] = $_POST['date'];
            $info['ip'] = $_POST['ip'];
            $info['page'] = $_POST['page'];
            $pag = 1000;
        }

        $dataProvider=new CActiveDataProvider('Counter',array(
                        'criteria'=>$criteria,
                        'pagination'=>array(
                                'pageSize'=>$pag,
                        ),
        ));
        $this->render('index',array(
                'dataProvider'=>$dataProvider,
                'inf'=>$info,
        ));
    }
    public function actionView(){
        $this->layout = 'backend.views.layouts.column2';
        $criteria=new CDbCriteria;
        $criteria->condition='id_view=:id_view';
        $criteria->params=array(':id_view'=>$_GET['id']);

        $this->render('view',array(
            'model'=>Counter::model()->find($criteria),
        ));
        
    }
    public function actionEmptyInfo() {
        $this->render('index');
    }
}